<script>
    function send_message(frm){
        $('#private_messages_body').css("background", "gray");
        $('#private_messages_body').css("opacity", "0.2");
    $.ajax({
    type: "POST",
    url: $(frm).attr('action'),
    data: $(frm).serialize(),
    success: function(data){
        if($('#private_messages_body').val() != ''){
            $('#private_messages_list_ul').append('<li>'+$('#private_messages_body').val()+'</li>')
            $('#private_messages_body').val('');
        }
        $('.notification_mesage').show();
        $('.notification_mesage').html(data);
        
        $('#private_messages_body').css("background", "white");
        $('#private_messages_body').css("opacity", "1");
    }
 });
 return false;
 }
 </script>
<ul id="private_messages_list_ul">
<?php foreach($messages as $msg){ ?>
<li class="">
    <div class="sender_name"><?php echo sfGuardUserTable::getInstance()->find($msg['sender_id']) ?>
                            <span class="modification_time"><?php echo $msg['modification_time']?></span></div>
    <div class="message_body"><?php echo $msg['body'] ?></div>
</li>
<?php } ?>
</ul>
 
<div class="private_messages_form" id="private_messages_form">
    <p class="notification_mesage" style="display: none;"></p> 
<form action="<?php echo url_for('private_messages/add') ?>" method="POST" onSubmit="send_message(this);return false">
    <label><?php echo __('Message body') ?></label>
    <input type="hidden" value="<?php echo $private_messages['sender_id']?>" name="receiver_id"></input>
    <textarea id="private_messages_body" name="private_messages_body"></textarea>
    <input type="submit" value="<?php echo __('Reply')?>" id="private_messages_form_submit"/>
</form>
    <div class="clear"></div>
</div>
 <div>
     <ul>
         <?php echo $helper->linkToList(array(  'params' =>   array(  ),  'class_suffix' => 'list',  'label' => 'Back to list',)) ?>
    </ul>
 </div>